<%@page import="org.yate.oa.model.LoginEntity"%>
<%@page import="java.text.SimpleDateFormat, java.util.Date"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set value="${pageContext.request.contextPath}" var="ctx" />
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>产品列表</title>
<link href="${ctx}/css/skin.css" rel="stylesheet" type="text/css" />
<link href="${ctx}/css/page.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="${ctx}/js/jquery.js"></script>
<script type="text/javascript" src="${ctx}/js/backOffice.js"></script>
<script type="text/javascript" src="${ctx}/js/jquery.myPagination.js"></script>
<script type="text/javascript">
	function dataFormat(date) {
		var year = date.getFullYear();
		var month = (date.getMonth() + 1) < 10 ? '0' + (date.getMonth() + 1)
				: (date.getMonth() + 1);
		var day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
		var hour = date.getHours() < 10 ? '0' + date.getHours() : date
				.getHours();
		var minute = date.getMinutes() < 10 ? '0' + date.getMinutes() : date
				.getMinutes();
		var second = date.getSeconds() < 10 ? '0' + date.getSeconds() : date
				.getSeconds();
		return year + "-" + month + "-" + day + " " + hour + ":" + minute + ":"
				+ second;
	}
	
	$(document).ready(function() {
		page(1);
	});
	
	function page(pageIndex) {
		$("#demo1").myPagination({
			currPage : pageIndex,
			ajax : {
				on : true,
				dataType : 'json',
				url : '${ctx}/highVol/post',
				callback : 'showData',
				param : {
					on : true,
					submitType : 'list'
				}
			}
		});
	}

	function resetTask(pid, ttype) {
		if (confirm("您确定要撤销本次" + ttype + "？")) {
			var obj = {};
			obj.type = 'resetTask';
			obj.id = pid;
			$.ajax({
				type : 'post',
				dataType : 'json',
				data : obj,
				url : '${ctx}/task/post',
				success : function(data) {
					if (data.code == 200) {
						page(1);
						$.msgbox.show({
							message : data.data,
							icon : 'ok'
						});
					} else {
						$.msgbox.show({
							message : data.data,
							icon : 'no'
						});
					}
				}
			});
		}
	}

	function showData(data) {
		var rows = data.data.rows;
		var str = '';
		var tmpLeave;
		for ( var i = 0; i < rows.length; i++) {
			str += '<tr>';
			str += '<td height="30" class="left_txt2" align="middle">'
					+ ((currPage - 1) * 10 + (i + 1)) + '</td>';
			str += '<td height="30" class="left_txt2" align="middle">'
					+ (rows[i].status == "processing" ? "处理中" : "已完成")
					+ '</td>';
			str += '<td height="30" class="left_txt2" align="middle">'
					+ dataFormat(new Date(rows[i].creationDate)) + '</td>';
			str += '<td height="30" class="left_txt2" align="middle">'
					+ dataFormat(new Date(rows[i].beginDate)) + '</td>';
			str += '<td height="30" class="left_txt2" align="middle">'
					+ rows[i].days + '</td>';
			if (rows[i].leaveType == "personal") {
				tmpLeave = "事假";
			} else if (rows[i].leaveType == "sick") {
				tmpLeave = "病假";
			} else if (rows[i].leaveType == "marriage") {
				tmpLeave = "婚假";
			} else if (rows[i].leaveType == "funeral") {
				tmpLeave = "丧假";
			} else if (rows[i].leaveType == "maternity") {
				tmpLeave = "产假";
			} else if (rows[i].leaveType == "father") {
				tmpLeave = "父亲假";
			} else if (rows[i].leaveType == "visiting") {
				tmpLeave = "外派探亲假";
			} else if (rows[i].leaveType == "annual") {
				tmpLeave = "年假";
			}
			str += '<td height="30" class="left_txt2" align="middle">'
					+ tmpLeave + '</td>';
			str += '<td height="30" class="left_txt2">' + rows[i].remark
					+ '</td>';
			if (rows[i].status == "processing") {
				str += '<td height="30" class="left_txt2"><a href="javascript:void(0);" onclick="resetTask('
						+ rows[i].id + ', \'' + tmpLeave + '\')">撤销申请</a></td>';
			} else {
				str += '<td height="30" class="left_txt2">&nbsp;</td>';
			}
			str += '</tr>';
		}
		$('#staffs').html('').html(str);
	}
	
	function deleteFn(id){
		$.ajax({
			type : 'delete',
			url : '${ctx}/highVol/delete?id='+id,
			dataType : 'json',
			success : function(data) {
				
			}
		});
	}
</script>
</head>
<body>
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
		<tr>
			<td width="17" height="29" valign="top"
				background="${ctx}/images/mail_leftbg.gif"><img
				src="${ctx}/images/left-top-right.gif" width="17" height="29" /></td>
			<td width="" height="29" valign="top"
				background="${ctx}/images/content-bg.gif"><table width="100%"
					height="31" border="0" cellpadding="0" cellspacing="0"
					class="left_topbg" id="table2">
					<tr>
						<td height="31"><div class="titlebt">产品列表</div></td>
					</tr>
				</table></td>
			<td width="16" valign="top"
				background="${ctx}/images/mail_rightbg.gif"><img
				src="${ctx}/images/nav-right-bg.gif" width="16" height="29" /></td>
		</tr>
		<tr>
			<td height="71" valign="middle"
				background="${ctx}/images/mail_leftbg.gif">&nbsp;</td>
			<td valign="top" bgcolor="#F7F8F9"><table width="100%"
					height="138" border="0" cellpadding="0" cellspacing="0">
					<tr>
						<td height="13" valign="top">&nbsp;</td>
					</tr>
					<tr>
						<td valign="top"><table width="98%" border="0" align="center"
								cellpadding="0" cellspacing="0">
								<tr>
									<td class="left_txt">当前位置：组合型地下式变压器 > 产品列表<span style="float: right;"><input type="button" value="添加产品" onclick="javascript:location.href='${ctx}/jsp/transformer/combin/add.jsp'"></span></td>
								</tr>
								<tr>
									<td height="20"><table width="100%" height="1" border="0"
											cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">
											<tr>
												<td></td>
											</tr>
										</table></td>
								</tr>
								<tr>
									<td><table width="100%" height="31" border="0"
											cellpadding="0" cellspacing="0" class="nowtable">
											<tr>
												<td class="left_bt2">&nbsp;&nbsp;&nbsp;&nbsp;产品列表</td>
											</tr>
										</table></td>
								</tr>
								<tr>
									<td width="100%" valign="top"
										style="min-height: 350px; height: 350px;">
										<table class="tblExcel" cellpadding="0" cellspacing="0">
											<thead>
												<td height="30" width="" class="left_txt2" align="middle">ID</td>
												<td height="30" width="" class="left_txt2" align="middle">容量</td>
												<td height="30" width="" class="left_txt2" align="middle">高压</td>
												<td height="30" width="" class="left_txt2" align="middle">低压</td>
												<td height="30" width="" class="left_txt2" align="middle">相数</td>
												<td height="30" width="" class="left_txt2">高压配置型式</td>
												<td height="30" width="" class="left_txt2">变压配置型式</td>
												<td height="30" width="" class="left_txt2">操作</td>
											</thead>
											<tbody id="staffs">
												<c:forEach items="${p.rows}" var="obj">
												<tr>
													<td>${obj.id}</td>
													<td>${obj.kav}</td>
													<td>${obj.highVol}</td>
													<td>${obj.lowVol}</td>
													<td>${obj.boxNum}</td>
													<td>${obj.highVolConf}</td>
													<td>${obj.voltageConf}</td>
													<td><input type="button" value="更新" onclick="javascript:location.href='${ctx}/jsp/highVol/modify.jsp?id=222'"><input type="button" value="删除" onclick="deleteFn('111')"></td>
												</tr>
												</c:forEach>
											</tbody>
										</table>
										<div id="demo1"></div>
									</td>
								</tr>
							</table></td>
					</tr>
				</table></td>
			<td background="${ctx}/images/mail_rightbg.gif">&nbsp;</td>
		</tr>
		<tr>
			<td valign="middle" background="${ctx}/images/mail_leftbg.gif"><img
				src="${ctx}/images/buttom_left2.gif" width="17" height="17" /></td>
			<td height="17" valign="top"
				background="${ctx}/images/buttom_bgs.gif"><img
				src="${ctx}/images/buttom_bgs.gif" width="17" height="17" /></td>
			<td background="${ctx}/images/mail_rightbg.gif"><img
				src="${ctx}/images/buttom_right2.gif" width="16" height="17" /></td>
		</tr>
	</table>
</body>
</html>